-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix from_json implementation for pair/tuple #708
fix from_json implementation for pair/tuple #708
Conversation
@theodelrieu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nlohmann, @himikof and @t-b to be potential reviewers. |
@@ -262,11 +263,12 @@ TEST_CASE("constructors") | |||
|
|||
SECTION("std::tuple") | |||
{ | |||
const auto t = std::make_tuple(1.0, "string", 42, std::vector<int> {0, 1}); | |||
const auto t = std::make_tuple(1.0, std::string{"string"}, 42, std::vector<int> {0, 1}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to change "string"
to std::string{"string"}
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it was deduced as a const char*
which you can not retrieve with get
.
Introduced by 6e4910d Fixes nlohmann#707
15c01a8
to
bb1b4c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
{ | ||
p = {j.at(0), j.at(1)}; | ||
p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that we'd have to support something like pair<int,int>? I think you'll save yourself a patch if you use get<0> and get<1> instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understood your point. Are you talking about std::get
?
I don't see how it could be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, you're right. I was talking about std::get here, which is not what you're doing at all. I mis-read it. What you have looks good!
Thanks! |
Introduced by 6e4910d
Fixes #707